package com.lxy.aimin.auth.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.EntityMapping;
import com.lxy.aimin.ds.annotation.DictTranslate;
import lombok.Data;

import java.util.List;

@TableName("user")
@Data
public class User {

    @TableId(type = IdType.AUTO)
    int id;

    @TableField(value = "pid")
    int pid;

    @TableField(value = "username")
    String username;

    @TableField(value = "password")
    String password;

    @TableField(value = "sex")
    @DictTranslate(valueTo = "sexName")
    int sex;

    @TableField(exist = false)
    String sexName;


    /**
     * 查询上级 一对一
     */
    @TableField(exist = false)
    @EntityMapping(thisField = "pid", joinField = "id")
    private User parentUser;


    /**
     * 查询地址 (一对多)
     */
    @TableField(exist = false)
    @EntityMapping(thisField = "id", joinField = "userId")
    private List<Address> addressList;
}
